<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layuiAdmin 管理员 iframe 框</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="${pageContext.request.contextPath }/back/layui/css/layui.css" media="all">
</head>
<body>

  <div class="layui-form" lay-filter="layuiadmin-form-admin" id="layuiadmin-form-admin" style="padding: 20px 30px 0 0;">
  	<div class="layui-form-item">
      <label class="layui-form-label">房间号</label>
      <div class="layui-input-inline">
        <input type="text" name="roomNum" id="roomNum" lay-verify="required" placeholder="请输入房间号" autocomplete="off" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">房间类型</label>
      <div class="layui-input-inline">
        <select name="rt_cl_room" id="rtName" lay-verify="required">
            <option value="">请选择</option>
        </select>
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">所处楼层</label>
      <div class="layui-input-inline">
        <input type="text" id="roomFloog" name="roomFloog" placeholder="请输入房间位置" lay-verify="required" autocomplete="off" class="layui-input">
      </div>
    </div>

    <div class="layui-form-item">
      <label class="layui-form-label">房间电话</label>
      <div class="layui-input-inline">
        <input type="text" id="roomTel" name="room_tel" lay-verify="phone" placeholder="请输入房间电话" autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-item">
      <label class="layui-form-label">房间状态</label>
      <div class="layui-input-inline">
        <select name="rt_cl_room" id="roomStatus" lay-verify="required">
              	<option value="">请选择</option>
                <option value="0">空闲</option>
                <option value="1">已入住</option>
                <option value="2">已预约</option>
                <option value="3">停用</option>
              </select>
      </div>
    </div>
    <div class="layui-form-item layui-hide">
      <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-back-submit" value="确认">
    </div>
  </div>

  <script src="${pageContext.request.contextPath }/back/layui/layui.js"></script>
  <script>
  layui.config({
    base: '${pageContext.request.contextPath }/back/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'form'], function(){
    var $ = layui.$
    ,form = layui.form ;
  })
  </script>
</body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
  $(function() {
    // 对查询房间类型做动态显示
    $.ajax({
      type : "POST",
      url : "${pageContext.request.contextPath }/RoomTypeController/queryRtNameRoomType",
      dataType : "json",
      success : function(data) {
        $.each(data,function(index, obj) {
          //alert(obj.rtName);
          $("#rtName").append("<option value=\""+obj.rtName+"\">"+obj.rtName+"</option>");
        })
      }
    });
     //添加房间
     $("#LAY-user-back-submit").click(function () {
          var rtName=$("#rtName").val();
          var roomNum= $("#roomNum").val()*1;
          var roomTel=$("#roomTel").val();
          var roomFloog=$("#roomFloog").val();
          var roomStatus=$("#roomStatus").val()*1;
         var rtId=0;
         $.ajax({
             type : "POST",
             url : "${pageContext.request.contextPath }/RoomTypeController/getqueryAllRoomType?rtName="+rtName,
             dataType : "json",
             success : function(data) {
                 $.each(data.data,function(index, obj) {
                     // alert(obj.rtId);
                     rtId= obj.rtId;

                     $.ajax({
                         type : "POST",
                         url : "${pageContext.request.contextPath }/RoomInfosController/addRoomInfo",
                         data : {
                             rtId:rtId,
                             roomNum:roomNum,
                             roomFloog:roomFloog,
                             roomTel:roomTel,
                             roomStatus:roomStatus
                         },
                         dataType : "json",
                         success : function(data) {
                             $("#roomNum").val("");
                             $("#roomTel").val("");
                             $("#roomFloog").val("");
                         }
                     });

                 })

             }
         })
     })


  });
</script>

</html>